import 'package:chatgpt/model/message.dart';
import 'package:flutter/material.dart';

class ChatScreen extends StatelessWidget {

  final List<Message> messages = [
    Message(content: "Hello", isUser: true, timestamp: DateTime.now()),
    Message(content: "How are you?", isUser: false, timestamp: DateTime.now()),
    Message(content: "Fine, Thank you. And you?", isUser: true, timestamp: DateTime.now()),
    Message(content: "I am fine.", isUser: false, timestamp: DateTime.now()),
  ];

  ChatScreen({super.key});

  


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Chat'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          children: [
            Expanded(
              child: ListView.separated(itemBuilder: (context, index) {
              return Row(
                children: [
                  CircleAvatar(
                    child: Text(messages[index].isUser ? 'A' : 'GPT'),
                  ),
                  const SizedBox(width: 8,),
                  Text(messages[index].content),
                ],
              );
            }, separatorBuilder: (context, index) => const Divider(
              height: 16,
            ), itemCount: messages.length),),
            TextField(
              decoration: InputDecoration(
                hintText: 'Type a message',
                suffixIcon: IconButton(
                  onPressed: (){},
                  icon: const Icon(
                    Icons.send,
                  ),
                )
              ),
            )
          ],
        ),
      ),
    );    
  }

}